/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ADT;


import static ADT.Values.*;;
/**
 *
 * @author Martin
 */
/**
 *
 * @author Martin
 */
public class AccInMss extends Scalar implements Acc {
    private final double acc;
    
    public AccInMss(double  acc){this.acc =  acc;} 
    
    @Override public boolean isZero(){ return acc==0.0; }
    @Override public boolean isValid(){ return true; }

    @Override
    public Acc inverse(){return new AccInMss(this.acc * -1);}
    
    @Override
    public double  mss(){return acc;}
       
    @Override public Acc add(Acc acc){return valueOf(this.mss() + acc.mss());}
    @Override public Acc sub(Acc acc){return valueOf(this.mss() - acc.mss());}
    @Override public Acc div(double factor){return valueOf(this.acc / factor);}
    @Override public  Acc mul(double factor){return valueOf(this.acc * factor);}
    
    @Override public double div(Acc acc){return this.acc / acc.mss();}
    
    @Override public Speed mul(TimeDiff time){return speedInMs(acc * time.s()); }
    @Override public Force mul(Mass mass){ return forceInN(acc * mass.kg()); }
    
    public String toString(){return String.format("Acc: %.2f M/S^2", this.acc);}
    
    @Override public int compareTo(Acc acc){return Double.compare(this.acc, acc.mss());}
    
    @Override public boolean equals(Object o){
        if(this == o) return true;
        if(!(o instanceof AccInMss)) return false;
        return this.compareTo((AccInMss)o) == 0;
    }
    
    
    public static Acc valueOf(double acc){
        return new AccInMss(acc);
    }
    
    @Override
    public int hashCode(){
        return hashDouble(acc);
    }

}